package com.itheima;

import cn.jiguang.common.resp.APIConnectionException;
import cn.jiguang.common.resp.APIRequestException;
import cn.jpush.api.JPushClient;
import cn.jpush.api.push.model.Platform;
import cn.jpush.api.push.model.PushPayload;
import cn.jpush.api.push.model.audience.Audience;
import cn.jpush.api.push.model.notification.AndroidNotification;
import cn.jpush.api.push.model.notification.Notification;

public class JpushDemo {

    public static void main(String[] args) throws APIConnectionException, APIRequestException {

        //构建推送客户端
        JPushClient jPushClient = new JPushClient("c7e8e44b63d95ec9bc94f965", "55de5d60083f940ffdd34c32");

        //组装推送对象
        PushPayload payload = PushPayload.newBuilder()
                .setPlatform(Platform.all()) //全平台
                .setAudience(Audience.registrationId("120c83f7608109fc2a9")) //推送目标用户
                .setNotification(Notification.newBuilder().addPlatformNotification(
                        AndroidNotification.newBuilder().setTitle("申请加入").setAlert("xxx 申请加入企业,请及时审批").build()).build())
                .build();

        //推送消息
        for (int i = 0; i < 10; i++) {
            jPushClient.sendPush(payload);
        }

    }

}
